﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace BingZi.HY.Core.SearchEngine.Store
{
    /// <summary>
    /// 存储目录操作
    /// </summary>
    public class StoreChange
    {

        private static string tagDirectory;
        /// <summary>
        /// 获取当前的标示目录
        /// </summary>
        public static string TagDirectory
        {
            get
            {
                if (String.IsNullOrEmpty(tagDirectory))
                {

                    tagDirectory = string.Format("{0}{1}", HttpRuntime.AppDomainAppPath, string.Format("SearchStore\\{0}\\", BingZi.HY.Core.SearchEngine.Configuration.Directorys.TagStore));
                    if (String.IsNullOrEmpty(tagDirectory))
                    {
                        tagDirectory = (new System.IO.FileInfo("Index")).FullName;
                    }

                    //检查目录是否存在
                    if (!System.IO.Directory.Exists(tagDirectory))
                        System.IO.Directory.CreateDirectory(tagDirectory);//创建不存在的目录
                }
                return tagDirectory;
            }
        }

       










        /// <summary>
        /// 执行全文检索目录变更
        /// </summary>
        public static void Execute()
        {
            StoreChange sc = new StoreChange();

            //删除指定存储目录下文件
          sc.  DeleteStore();

          //复制文件到指定存储目录
          sc.  CopyStore();

          //改变标示到另外一个文件夹
          sc.ChangeTag();
        }



        /// <summary>
        /// 删除指定存储目录下文件
        /// </summary>
        private void DeleteStore()
        {
            //获取待操作的目录位置



          
        }

        /// <summary>
        /// 复制文件到指定存储目录
        /// </summary>
        private void CopyStore()
        {
            //获取待操作的目录位置



            
        }

        /// <summary>
        /// 改变标示到另外一个文件夹
        /// </summary>
        private string ChangeTag()
        {
            //改变目录标示
            if (BingZi.HY.Core.SearchEngine.Configuration.Directorys.TagStore == "A")
                BingZi.HY.Core.SearchEngine.Configuration.Directorys.TagStore = "B";
            else
                BingZi.HY.Core.SearchEngine.Configuration.Directorys.TagStore = "A";


            return BingZi.HY.Core.SearchEngine.Configuration.Directorys.TagStore;
        }



    }
}
